package com.shouhuobao.take.input;

import com.iseastar.guojiang.BaseActivity;
import com.shouhuobao.station.R;

import android.content.Intent;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import java.text.MessageFormat;

/**
 * 包裹签收、结果界面
 * 
 * @author coffee<br>
 *         2017年7月1日上午11:04:08
 */
public class ParcelInputResultActivity extends BaseActivity implements OnClickListener {

	private TextView mStorageCode;
	private TextView mTips;

	@Override
	protected void findViewById() {
		setContentView(R.layout.take_parcel_input_result);
		super.findViewById();
		getAppTitle().setCommonTitle("包裹签收");

		findViewById(R.id.submit_1).setOnClickListener(this);
		findViewById(R.id.submit_2).setOnClickListener(this);
		//
		String storageCode = getIntent().getStringExtra("storageCode");
		Integer shelves = getIntent().getIntExtra("shelves",0);
		String expressCompanyName = getIntent().getStringExtra("expressCompanyName");
		mStorageCode = (TextView) findViewById(R.id.parcel_storage_code);
		mTips  = (TextView) findViewById(R.id.parcel_storage_tip);
//		storageCode = new StringBuilder(storageCode).insert(5, "-").insert(1, "-").toString();
		mStorageCode.setText(storageCode);
		String tip = "<font color=#888888>并将包裹放到</font><font  color=#ff001f><big><big>{0}</big></big></font ><font color=#888888>号（{1}）货架上</font>";
		mTips.setText(Html.fromHtml(MessageFormat.format(tip,shelves,expressCompanyName)));
		int left = getResources().getIdentifier("title_left_switcher","id", getPackageName());
		findViewById(left).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.putExtra("finish", true);
				setResult(RESULT_OK, intent);
				finish();
			}
		});
	}

	@Override
	public void onClick(View v) {
		Intent data = new Intent();
		switch (v.getId()) {
		case R.id.submit_1:// 返回到首页
			data.putExtra("finish", true);
			setResult(RESULT_OK, data);
			finish();
			break;
		case R.id.submit_2:
			data.putExtra("finish", false);
			setResult(RESULT_OK,data);
			finish();
			break;
		}
	}
	
	@Override
	public void finish() {
		super.finish();
	}

}
